import cgi
import urllib
import sys

from xml.dom.minidom import parseString

url = 'http://search.twitter.com/search.atom?q='+urllib.quote_plus(sys.argv[1])
#print url 
resp = urllib.urlopen(url)

tweets = resp.read()
count = 0
response = "<div class='carousel' id='container'><ol>"
#print tweets

#Parse the XML.
twitterDom = parseString(tweets)

# Find all the status tweets.
for tweet in twitterDom.getElementsByTagName("content"):
  for tweetParts in tweet.childNodes:
    if count < 10:
      response += "<li>"+tweetParts.nodeValue.encode('utf-8')+"</li>"
      count = count + 1
response += "</ol></div>"
print response
